Skip to content

provide option to return jwt id token with x.509 instead of ntoken#3208

Merged
havetisyan merged 1 commit intomasterfrom
jwt-id
Feb 26, 2026
Merged

provide option to return jwt id token with x.509 instead of ntoken#3208
havetisyan merged 1 commit intomasterfrom
jwt-id

Conversation

@havetisyan
Copy link
Copy Markdown
Collaborator

@havetisyan havetisyan commented Feb 26, 2026

Description

Contribution Checklist:

  • The pull request does not introduce any breaking changes
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Attach Screenshots (Optional)

Signed-off-by: Henry Avetisyan <hga@yahooinc.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @havetisyan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the ZTS server's capability to issue identity tokens. Previously, only proprietary NTokens were returned when requesting a service token with an X.509 certificate. This change introduces an option to return a standard JWT ID token, offering greater interoperability and alignment with modern identity standards for services consuming these tokens.

Highlights

  • JWT ID Token Support for X.509 Certificate Requests: Introduced a new configuration property, athenz.zts.cert_request_token_type_jwt, allowing the ZTS server to return a JWT ID token instead of the proprietary NToken when a service token is requested alongside an X.509 certificate.
  • Configurable Token Type: The choice between returning a proprietary PrincipalToken or a standard JWT ID token is now controlled by a server-side property, providing flexibility for clients that prefer JWTs.
  • Refactored Token Generation Logic: The logic for generating service tokens during X.509 certificate registration has been refactored into a new helper method, getCertRequestServiceToken, which conditionally generates either a PrincipalToken or a JWT ID token.
  • JWT SVID Audience Validation: Added validation to ensure that a JwtSVIDAudience is provided when requesting a JWT SVID, preventing token generation with missing critical claims.
  • Comprehensive Unit Tests: Added extensive unit tests to cover both PrincipalToken and JWT ID token generation paths, including scenarios for default audience, nonce generation, different key types (EC, RSA), and expiry time calculations.
Changelog
  • servers/zts/conf/zts.properties
    • Added a new configuration property athenz.zts.cert_request_token_type_jwt to enable JWT ID token generation for X.509 certificate requests.
  • servers/zts/src/main/java/com/yahoo/athenz/zts/ZTSConsts.java
    • Defined a new constant ZTS_PROP_CERT_REQUEST_TOKEN_TYPE_JWT for the new configuration property.
  • servers/zts/src/main/java/com/yahoo/athenz/zts/ZTSImpl.java
    • Added a new protected boolean member instanceRegisterTokenTypeJWT to store the value of the new configuration property.
    • Loaded the athenz.zts.cert_request_token_type_jwt property into the instanceRegisterTokenTypeJWT member during configuration loading.
    • Refactored the service token generation logic from postInstanceX509CertificateRegister into a new private helper method getCertRequestServiceToken.
    • Implemented conditional logic within getCertRequestServiceToken to generate either a PrincipalToken or a JWT ID token based on the instanceRegisterTokenTypeJWT flag.
    • Added validation for the JwtSVIDAudience in postInstanceJWTRegister to ensure it's not empty.
  • servers/zts/src/test/java/com/yahoo/athenz/zts/ZTSImplTest.java
    • Imported PrincipalToken class.
    • Added a new test testPostInstanceJWTRegisterEmptyAudience to verify audience validation for JWT SVID requests.
    • Added several new unit tests for the getCertRequestServiceToken method, covering PrincipalToken generation, JWT ID token generation with custom and default audience/nonce, different key types, and expiry time calculations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature to allow returning a JWT ID token instead of the proprietary ntoken when requesting an x.509 certificate. The implementation is clean, with the logic for token generation refactored into a new method for better separation of concerns. The new configuration property is disabled by default, which is a safe approach. The accompanying tests are comprehensive, covering both the new JWT generation path and the existing token generation. The suggestion to improve the robustness of the new tests by ensuring system properties are restored correctly has been kept, as it is a good practice for test stability.

@havetisyan havetisyan merged commit 0d1379d into master Feb 26, 2026
8 checks passed
@havetisyan havetisyan deleted the jwt-id branch February 26, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants